package algorithm;

import java.util.*;

public class CountDoubleNum_DeepSeek {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            String line = scanner.nextLine().trim();

            // 检查是否结束输入
            if (line.equals("-1")) {
                break;
            }

            // 解析输入行，去掉最后的0
            String[] tokens = line.split("\\s+");
            List<Integer> numbers = new ArrayList<>();

            for (String token : tokens) {
                int num = Integer.parseInt(token);
                if (num == 0) {
                    break; // 遇到0表示当前行结束
                }
                numbers.add(num);
            }

            // 计算满足条件的数对数量
            int count = countDoublePairs(numbers);
            System.out.println(count);
        }

        scanner.close();
    }

    private static int countDoublePairs(List<Integer> numbers) {
        int count = 0;
        Set<Integer> numberSet = new HashSet<>(numbers);

        // 遍历所有数字，检查是否存在其两倍的数字
        for (int num : numbers) {
            if (numberSet.contains(num * 2)) {
                count++;
            }
        }

        return count;
    }
}
